package com.example.controller;

import com.example.common.response.Result;
import com.example.service.LikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/likes")
public class LikeController {
    @Autowired
    private LikeService likeService;

    @PostMapping("/{postId}")
    public Result<Void> likePost(@PathVariable Long postId, @RequestParam Long userId) {
        likeService.likePost(userId, postId);
        return Result.success(null);
    }

    @DeleteMapping("/{postId}")
    public Result<Void> unlikePost(@PathVariable Long postId, @RequestParam Long userId) {
        likeService.unlikePost(userId, postId);
        return Result.success(null);
    }

    @GetMapping("/{postId}/status")
    public Result<Boolean> hasLiked(@PathVariable Long postId, @RequestParam Long userId) {
        return Result.success(likeService.hasLiked(userId, postId));
    }
} 